/**
 * 
 */
package com.upstairstechnology.oi.notification.email.resolver;

import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Base implementation for obtaining email addresses from SCM user ids.
 * 
 * @author Jeff Jensen
 */
public abstract class AbstractEmailResolver implements EmailResolver {
    /** Logger instance. */
    private static final Logger LOGGER =
            LoggerFactory.getLogger(AbstractEmailResolver.class);

    /**
     * Output the process' environment variables to the log.
     * 
     * @param processBuilder
     *            The process with the environment.
     */
    protected void logEnvironment(ProcessBuilder processBuilder) {
        LOGGER.error("Environment variables in email resolver process");
        LOGGER.error("-----------------------------------------------");
        Map<String, String> envMap = processBuilder.environment();
        Set<Entry<String, String>> entrySet = envMap.entrySet();

        for (Entry<String, String> entry : entrySet) {
            String key = entry.getKey();
            String value = entry.getValue();

            LOGGER.error("{}={}", key, value);
        }
    }
}
